home *** CD-ROM | disk | FTP | other *** search
- ; ASM2.ASM
- ; Prints messages get keyboard input and has control flow
-
- DOSSEG
- .MODEL SMALL
- .STACK 200h
- .DATA
-
- Prompt db 13,10,"Do you want to be prompted again? (Y/N) $"
- NoMessage db 13,10,"Ok, then I won't prompt you anymore.$"
- YesMessage db 13,10,"Here comes another prompt!$"
- UnKnownKey db 13,10,"Please hit either Y or N.$"
-
- .CODE
-
- START:
- mov ax,@DATA ;moves the segment of data into ax
- mov ds,ax
-
- MainLoop:
- mov ah,9
- mov dx,offset Prompt
- int 21h ;print a message
-
- mov ah,0
- int 16h ;get a key, returned in AX
- ;AL is the ASCII part
- ;AH is the SCAN CODE
- push ax
- mov dl,al
- mov ah,2
- int 21h ;print character in dl
- pop ax
-
- cmp al,"Y" ;was the character a 'Y'?
- jne NotYes ;nope it was Not Equal
-
- mov ah,9
- mov dx,offset YesMessage
- int 21h
- jmp MainLoop
-
- NotYes:
- cmp al,"N" ;was the character a 'N'
- je ByeBye ;Yes, it was Equal
-
- mov dx,offset UnknownKey
- mov ah,9
- int 21h
- jmp MainLoop
-
- ByeBye:
- mov dx,offset NoMessage
- mov ah,9
- int 21h
-
- mov ax,4c00h ;Returns control to DOS
- int 21h ;MUST be here! Program will crash without it!
-
- END START
-